home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_exp_flash.cog < prev    next >
Text File  |  1998-02-25  |  4KB  |  150 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # EXP_FLASH.COG
  4. #
  5. # EXPLOSION SCRIPT - Flash Bomb
  6. #
  7. # [RF]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11. symbols
  12.  
  13. message     created
  14.  
  15. # Concussion damage explosion (very mild, but wide)
  16. template    conc_exp=+flashbomb_exp             local
  17.  
  18. # Fire damage explosion (nasty, but narrow)
  19. template    fire_exp=+flashfire_exp             local
  20.  
  21. sound       outSound=pistout1.wav               local
  22.  
  23. thing       flashb                              local
  24. thing       blinded                             local
  25.  
  26. vector      tempvec                             local
  27. flex        tempflex                            local
  28.  
  29. vector      blindedpos                          local
  30. vector      flashbpos                           local
  31.  
  32. int         flashbdist                          local
  33.  
  34. flex        blindradius=30.0                    local
  35. flex        maxblindtime=10.0                   local
  36. flex        blindtime                           local
  37.  
  38. end
  39.  
  40. # ========================================================================================
  41.  
  42. code
  43.  
  44. created:
  45.    flashb = GetSenderRef();
  46.  
  47. //   CreateThingNR(conc_exp, flashb);
  48. //   CreateThingNR(fire_exp, flashb);
  49.  
  50.    flashbpos = GetThingPos(flashb);
  51.  
  52.       // Do we need to blind ourselves?
  53.    blinded = GetLocalPlayerThing();
  54.    blindedpos = GetThingPos(blinded);
  55.  
  56.    flashbdist = VectorDist(blindedpos, flashbpos) * 10;
  57.  
  58.    if (flashbdist < (blindradius * 3))
  59.    if (!(GetActorFlags(blinded) & 0x100)) // Inanimate
  60.     if (HasLOS(blinded, flashb))
  61.    {
  62.          // If this is our flashbomb, then blink.
  63.       if (GetThingParent(flashb) == blinded)
  64.       {
  65.          SendMessageEx(GetThingClassCog(blinded), skill, 1036, -1, 0, 0);
  66.       }
  67.       else
  68.       {
  69.          blindtime = -2.0; // Signal that we should see the
  70.                            // flash, but not be blinded.
  71.  
  72.          if (HasLOS(blinded, flashb))
  73.          if (flashbdist <= blindradius)
  74.          {
  75.             tempvec = VectorSub(flashbpos, blindedpos);
  76.             tempvec = VectorNorm(tempvec);
  77.             tempflex = VectorDot(tempvec, GetThingLVec(blinded));
  78.  
  79.                // Flash bomb is in view.
  80.             if (tempflex >= 0.60)
  81.                blindtime = (maxblindtime * (blindradius - flashbdist)) / blindradius;
  82.          }
  83.  
  84.          SendMessageEx(GetThingClassCog(blinded), skill, 1036, blindtime, 0, 0);
  85.       }
  86.    }
  87.  
  88.    // If we are a client, stop here.
  89.    if (IsMulti())
  90.       if (!IsServer())
  91.       {
  92.          DestroyThing(flashb);
  93.          Return;
  94.       }
  95.  
  96. // print("Looking...");
  97.  
  98.       // Check for other actor targets.
  99.    blinded = FirstThingInView(flashb, 180, blindradius, 0x004);
  100.  
  101.    while (blinded != -1)
  102.    {
  103. //    print("Found something...");
  104.  
  105. //       // Don't mess with inanimate objects.
  106. //    if (!(GetActorFlags(blinded) & 0x100))
  107. //       // Don't mess with other players.
  108. //    if (!(GetThingFlags(blinded) & 0x400))
  109.          // Double check LOS.
  110.       if (HasLOS(blinded, flashb))
  111.       {
  112.          blindedpos = GetThingPos(blinded);
  113.  
  114.          flashbdist = VectorDist(blindedpos, flashbpos) * 10;
  115.  
  116.          blindtime = (maxblindtime * (blindradius - flashbdist)) / blindradius;
  117.  
  118.          if (blindtime > 0)      // Sanity check.
  119.          {
  120.                // Give the thing a chance to react.
  121.             if (SendMessageEx(GetThingClassCog(blinded), skill, 1036, blindtime, blinded, 0) != 17)
  122.             {
  123.                   // Before going into the default handler.
  124.                SendMessageEx(GetInvCog(GetLocalPlayerThing(), 134), user0, blinded, blindtime, 0, 0);
  125.             }
  126.          }
  127.       }
  128.       //else
  129.       //{
  130.          //print("No LOS!");
  131.       //}
  132. //    else
  133. //    {
  134. //       print("Thing Flags: ");
  135. //       printint(GetThingFlags(blinded));
  136. //    }
  137. //    else
  138. //    {
  139. //       print("Actor Flags: ");
  140. //       printint(GetActorFlags(blinded));
  141. //    }
  142.  
  143.       blinded = NextThingInView();
  144.    }
  145.  
  146.       // Buh bye.
  147.    DestroyThing(flashb);
  148.    Return;
  149. end
  150.